<?php
	class Route {
		var $path_info;
		
		function route() {
			/*
			 * We are routing via $_SERVER['PATH_INFO'] if
			 * this global variable doesn't exist
			 * then rikas is not yet for you. Request the
			 * feature from erwinatuli@gmail.com
			 */
			if(!isset($_SERVER['PATH_INFO']))
				$this->path_info = array();
			else {
				$reindexed = array();
				$this->path_info = (explode('/',$_SERVER['PATH_INFO']));
				foreach($this->path_info as $i=>$val) {
					if($i==0)
						unset($this->path_info[$i]);
					else {
						$reindexed[] = $val;
					}
				}
				$this->path_info = $reindexed;
			}
		}
		function getController() {
			if(!isset($this->path_info[0])) {
				return false;
			}
			return $this->path_info[0];
		}
		function getMethod() {
			if(!isset($this->path_info[1])) {
				return false;
			}
			return $this->path_info[1];
		}
		function getParams() {
			if(count($this->path_info) < 2)
				return array();
			$params = array();
			for($i=2, $j=count($this->path_info); $i<$j; $i++) {
				$params[] = $this->path_info[$i];
			}
			return $params;
		}
	}

?>
